package com.bzframework.pro.entity;

import com.bzframework.pro.model.order.Product;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import org.hswebframework.ezorm.rdb.mapping.annotation.ColumnType;
import org.hswebframework.ezorm.rdb.mapping.annotation.JsonCodec;
import org.hswebframework.web.api.crud.entity.GenericEntity;
import org.hswebframework.web.crud.annotation.EnableEntityEvent;

import javax.persistence.Column;
import javax.persistence.Table;
import java.sql.JDBCType;
import java.util.List;

/**
 * @Author bingzhong
 * @Date 2025/3/21 10:46
 * @Description 订单接口
 */
@Table(name = "beiya_order")
@Getter
@Setter
@Schema(description = "订单接口")
@EnableEntityEvent //开启实体类crud事件
public class OrderEntity extends GenericEntity<String> {

    @Column
    @Schema(description = "创建时间，格式yyyyMMddHHmmss")
    private String createtime;

    @Column
    @Schema(description = "更新时间，格式yyyyMMddHHmmss")
    private String updatetime;

    @Column
    @Schema(description = "学员id")
    private String student_id;

    @Column
    @Schema(description = "订单类型")
    private String order_type;

    @Column
    @Schema(description = "订单编号")
    private String order_code;

    @Column
    @Schema(description = "下单日期，格式yyyyMMddHHmmss")
    private String order_date;

    @Column
    @Schema(description = "交费日期，格式yyyyMMddHHmmss")
    private String payment_date;

    @Column
    @Schema(description = "订单金额")
    private Double order_money;

    /**
     * TODO 接口文档不一致
     */
    @Column
    @Schema(description = "订单状态")
    private String order_status;

    @Column
    @Schema(description = "下单校区id")
    private String campus_id;

    @Column
    @ColumnType(javaType = String.class, jdbcType = JDBCType.LONGVARCHAR)
    @Schema(description = "订单备注")
    private String memo;

    @Column
    @Schema(description = "学员id")
    private String student_user_id;

    @Column
    @Schema(description = "交费记录id，当为一串零时，说明该订单还未付款")
    private String charge_id;

    @Column
    @Schema(description = "支付之后生成的交易号")
    private String transaction_id;

    @Column
    @Schema(description = "支付类型，1必须全款 2定金支付")
    private Integer pay_type;

    @Column
    @Schema(description = "支付金额")
    private Double pay_fact;

    @Column
    @Schema(description = "是否使用了折扣 1是 0否")
    private Integer is_use_discount;

    @Column
    @Schema(description = "是否使用了优惠券 1是 0否")
    private Integer is_use_coupon;

    @Column
    @Schema(description = "是否使用了积分 1是 0否")
    private Integer is_use_point;

    @Column
    @JsonCodec
    @Schema(description = "订单项目明细列表")
    @ColumnType(javaType = String.class, jdbcType = JDBCType.LONGVARCHAR)
    private List<Product> products;

    @Column
    @Schema(description = "电话号码")
    private String phone;


}
